﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace Kyers._50kweb.CoreData.User
{
    public partial class UserData : BaseEntity
    {
        public virtual string fullname { get; set; }
        public virtual string username { get; set; }
        public virtual string address { get; set; }
        public virtual string email { get; set; }
        public virtual string phone { get; set; }
        public virtual string job { get; set; }
        public virtual int age { get; set; }
     
        public virtual string indentify_number { get; set; }
        public virtual string sex { get; set; }
        public virtual DateTime dayofbirth { get; set; }
        public virtual string avatar { get; set; }
        public virtual DateTime createdate { get; set; }
        public virtual DateTime lastlogin { get; set; }
        public virtual string password { get; set; }
        
        public UserData()
        {
            fullname = "";
            username = "";
            email="";
            phone="";
            password="";
            indentify_number = "";
        }

        static UserData DynamicCast<T>(object row_data, object row_header) where T : UserData
        {
            // row_data : DataRow
            // row_header : DataColumnCollection
            UserData ret = new UserData();
            DataRow dt = (DataRow)row_data;

            foreach (DataColumn column in (DataColumnCollection)row_header)
            {
                switch (column.ColumnName)
                {
                    case "id":
                        ret.id = int.Parse(dt[column].ToString());
                        break;
                    case "guidid":
                        ret.guidid = new Guid((dt[column].ToString()));
                        break;
                    case "email":
                        ret.email = dt[column].ToString();
                        break;
                    case "phone":
                        ret.phone = dt[column].ToString();
                        break;
                    case "address":
                        ret.address = dt[column].ToString();
                        break;
                    case "dayofbirth":
                        ret.dayofbirth = DateTime.Parse(dt[column].ToString());
                        break;
                    case "avatar":
                        ret.avatar = dt[column].ToString();
                        break;
                    case "sex":
                        ret.sex = (dt[column].ToString());
                        break;
                    case "indentify_number":
                        ret.indentify_number = dt[column].ToString();
                        break;
                    case "createdate":
                        ret.createdate = DateTime.Parse(dt[column].ToString());
                        break;
                    case "lastlogin":
                        ret.lastlogin = DateTime.Parse(dt[column].ToString());
                        break;
                    case "password":
                        ret.password = (dt[column].ToString());
                        break;
                    case "fullname":
                        ret.fullname = (dt[column].ToString());
                        break;
                    case "username":
                        ret.username = (dt[column].ToString());
                        break;
                    case "job":
                        ret.job = (dt[column].ToString());
                        break;
                    case "age":
                        ret.age = int.Parse(dt[column].ToString());
                        break;
                    default:
                        break;

                }

            }
            return ret;
        }

    }
}
